package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.vo.ProductReviewVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TProductReviewsMapper;
import com.ruoyi.system.domain.TProductReviews;
import com.ruoyi.system.service.ITProductReviewsService;

/**
 * 商品评价Service业务层处理
 *
 * @author ruoyi
 * @date 2025-07-08
 */
@Service
public class TProductReviewsServiceImpl<QueryWrapper> implements ITProductReviewsService
{
    @Autowired
    private TProductReviewsMapper tProductReviewsMapper;

    /**
     * 查询商品评价
     *
     * @param id 商品评价主键
     * @return 商品评价
     */
    @Override
    public TProductReviews selectTProductReviewsById(Long id)
    {
        return tProductReviewsMapper.selectTProductReviewsById(id);
    }

    /**
     * 查询商品评价列表
     *
     * @param tProductReviews 商品评价
     * @return 商品评价
     */
    @Override
    public List<TProductReviews> selectTProductReviewsList(TProductReviews tProductReviews)
    {
        return tProductReviewsMapper.selectTProductReviewsList(tProductReviews);
    }

    /**
     * 新增商品评价
     *
     * @param tProductReviews 商品评价
     * @return 结果
     */
    @Override
    public int insertTProductReviews(TProductReviews tProductReviews)
    {
        tProductReviews.setCreateTime(DateUtils.getNowDate());
        return tProductReviewsMapper.insertTProductReviews(tProductReviews);
    }

    /**
     * 修改商品评价
     *
     * @param tProductReviews 商品评价
     * @return 结果
     */
    @Override
    public int updateTProductReviews(TProductReviews tProductReviews)
    {
        tProductReviews.setUpdateTime(DateUtils.getNowDate());
        return tProductReviewsMapper.updateTProductReviews(tProductReviews);
    }

    /**
     * 批量删除商品评价
     *
     * @param ids 需要删除的商品评价主键
     * @return 结果
     */
    @Override
    public int deleteTProductReviewsByIds(Long[] ids)
    {
        return tProductReviewsMapper.deleteTProductReviewsByIds(ids);
    }

    /**
     * 删除商品评价信息
     *
     * @param id 商品评价主键
     * @return 结果
     */
    @Override
    public int deleteTProductReviewsById(Long id)
    {
        return tProductReviewsMapper.deleteTProductReviewsById(id);
    }

    @Override
    public List<ProductReviewVO> getReviewsList(TProductReviews tProductReviews) {
        return tProductReviewsMapper.getReviewsList(tProductReviews);
    }

    @Override
    public void updateLikeCount(Long id) {
        tProductReviewsMapper.updateLikeCount(id);
    }

    @Override
    public Double  selectAverageRating() {
        return tProductReviewsMapper.selectAverageRating();
    }

}
